<template>
  <div class="files">
    <div class="files-header">
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item :to="{ path: '/user/home/menu' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item>我的申请</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="myOrder">
      <el-popover placement="bottom" trigger="click">
        <template :loading="loading">
          <!-- 随便给个data就行，否则无法弹出 -->
          <el-checkbox v-model="checked" @change="allChange">全选</el-checkbox>
          <br />
          <el-checkbox v-model="checked0">订单编号</el-checkbox>
          <br />
          <el-checkbox v-model="checked6">订单状态</el-checkbox>
          <br />
          <el-checkbox v-model="checked1">专利权人</el-checkbox>
          <br />
          <el-checkbox v-model="checked2">发明人</el-checkbox>
          <br />
          <el-checkbox v-model="checked3">专利名称</el-checkbox>
          <br />
          <el-checkbox v-model="checked4">专利类型</el-checkbox>
          <br />
          <el-checkbox v-model="checked5">代理人</el-checkbox>
          <br />
          <el-checkbox v-model="checked8">提交时间</el-checkbox>
          <br />
          <!-- <el-checkbox v-model="checked7">备注信息</el-checkbox><br /> -->
          <el-checkbox v-model="checked9">专属顾问</el-checkbox>
          <br />
        </template>
        <span slot="reference" class="tag2" @click=" ">
          <font color="#31A3FF">显示字段</font>
        </span>
      </el-popover>

      <!-- 列表查找 -->
      <span class="down-execel1">
        <Poptip v-model="showFilter" @on-popper-show="getAllAgent" placement="bottom-end">
          <a href="javascript:;" class="lookup-list">列表查找</a>
          <div slot="content">
            <Poptip v-model="showFilterCondition" placement="bottom-start" class="poptip-condition">
              <a href="javascript:;" class="poptip-condition-add">添加查找条件</a>
              <div slot="content" class="condition-list">
                <ul>
                  <li
                    v-for="(item, index) in columns"
                    :key="index"
                    class="poptip-condition-item"
                    @click="addFilterCondition(item)"
                  >{{item.label}}</li>
                </ul>
              </div>
            </Poptip>

            <el-form
              :model="conditionForm"
              ref="conditionForm"
              label-min-width="120px"
              class="demo-dynamic"
              @submit.native.prevent
            >
              <template v-for="(condition, index) in conditionForm.condition">
                <el-form-item
                  v-if="condition.label !== '发明人' && condition.label !== '代理人' "
                  :label="condition.label"
                  :key="condition.key"
                  :prop="'condition.' + index + '.value'"
                  :rules="{ required: true, message: condition.label +'不能为空'}"
                >
                  <el-select
                    v-if="condition.label === '订单状态'"
                    v-model="condition.value"
                    placeholder="请选择订单状态"
                    size="small"
                  >
                    <el-option label="待接单" value="待接单"></el-option>
                    <el-option label="代理人撰写中" value="代理人撰写中"></el-option>
                    <el-option label="案件内审中" value="案件内审中"></el-option>
                    <el-option label="案件修改中" value="案件修改中"></el-option>
                    <el-option label="定稿文件发送中" value="定稿文件发送中"></el-option>
                    <el-option label="发明人确认定稿中" value="发明人确认定稿中"></el-option>
                    <el-option label="上报文件上传中" value="上报文件上传中"></el-option>
                    <el-option label="文件格式审核中" value="文件格式审核中"></el-option>
                  </el-select>
                  <el-select
                    size="small"
                    filterable
                    v-model="condition.value"
                    v-else-if="condition.label === '代理人'"
                  >
                    <el-option
                      v-for="item in agentOptions"
                      :key="item.id"
                      :label="item | agentNumAddName"
                      :value="item.id"
                    ></el-option>
                  </el-select>
                  <el-select
                    size="small"
                    filterable
                    v-model="condition.value"
                    v-else-if="condition.label === '专属顾问'"
                  >
                    <el-option
                      v-for="item in processOptions"
                      :key="item.id"
                      :label="item.email_work.split('@')[0].split('followup')[1]"
                      :value="item.id"
                    ></el-option>
                  </el-select>

                  <el-date-picker
                    v-model="submitTime"
                    type="daterange"
                    placeholder="选择日期"
                    value-format="yyyy-MM-dd"
                    size="small"
                    :validate-event="false"
                    @input="changInput"
                    v-else-if="condition.label === '提交时间'"
                  ></el-date-picker>
                  <el-select
                    v-else-if="condition.label === '专利类型'"
                    v-model="condition.value"
                    placeholder="请选择专利类型"
                    size="small"
                  >
                    <el-option label="发明专利" value="发明专利"></el-option>
                    <el-option label="实用新型" value="实用新型"></el-option>
                    <el-option label="外观设计" value="外观设计"></el-option>
                    <el-option label="不确定" value="不确定"></el-option>
                  </el-select>
                  <el-input
                    v-else
                    size="small"
                    v-model="condition.value"
                    @keyup.enter.native="submitsearch('conditionForm')"
                  ></el-input>
                  <!-- 删除 -->
                  <i
                    class="el-icon-close recommend-close"
                    @click.stop="removeDomain(condition)"
                    style="font-size:25px;margin-left:20px;vertical-align:middle"
                  ></i>
                </el-form-item>
                <el-form-item
                  v-else
                  :label="condition.label + ''"
                  :key="condition.key"
                  :prop="'condition.' + index + '.value'"
                  :rules="{ required: true, message: condition.label +'不能为空'}"
                >
                  <!-- 添加空格 对齐 -->
                  <label slot="label">{{condition.label}}&emsp;</label>
                  <el-input
                    size="small"
                    v-model="condition.value"
                    @keyup.enter.native="submitsearch('conditionForm')"
                  ></el-input>
                  <!-- 删除 -->
                  <i
                    class="el-icon-close recommend-close"
                    @click.stop="removeDomain(condition)"
                    style="font-size:25px;margin-left:20px;vertical-align:middle"
                  ></i>
                </el-form-item>
              </template>
            </el-form>

            <div class="btns">
              <el-button @click.stop="resetForm('conditionForm')" size="mini">重置</el-button>
              <el-button @click="submitsearch('conditionForm')" size="mini">查询</el-button>
            </div>
          </div>
        </Poptip>
      </span>
      <span class="soft-writing1" @click="toSoftware">
        {{`我的软著：${userData.software ? userData.software : 0 }`}}
      </span>
      <span @click="clickPatent" :class="softConfirm ? 'soft-patent1' : 'no-partent1' ">
        {{`我的专利：${userData.processing ? userData.processing : 0 }`}}
      </span>
      <span @click="clickPrompt" :class="softConfirm ? 'click-confirm1' : 'soft-confirm1' ">
        {{`您待确认的专利数：${userData.confirm_total ? userData.confirm_total : 0 }`}}
      </span>

      <el-table
        v-if="table_show"
        ref="orderTb"
        filters
        id="orderTable"
        :data="tableData"
        border
        stripe
        style="width: 100%;"
        height="87%"
        v-loading="loading"
        @sort-change="tableSortChange"
        @row-click="selectRow"
      >
        <el-table-column
          show-overflow-tooltip
          v-if="checked0"
          prop="order_number"
          label="订单编号"
          min-width="200"
          align="left"
          sortable="custom"
        ></el-table-column>
        <el-table-column
          show-overflow-tooltip
          v-if="checked6"
          prop="status"
          label="订单状态"
          min-width="130"
          align="left"
          sortable="custom"
        >
          <template slot-scope="scope">
            <div class="more">
              <span v-if="scope.row.status == '待接单'" class="font_waiting">{{scope.row.status}}</span>
              <span
                v-else-if="scope.row.status == '代理人撰写中'"
                class="font_compose"
              >{{scope.row.status}}</span>
              <span v-else-if="scope.row.status == '案件内审中'" class="font_audit">{{scope.row.status}}</span>
              <span v-else-if="scope.row.status == '案件修改中'" class="font_edit">{{scope.row.status}}</span>
              <span
                v-else-if="scope.row.status == '上报文件上传中'"
                class="font_upload"
              >{{scope.row.status}}</span>
              <span v-else-if="scope.row.status == '定稿文件发送中'" class="font_send">{{scope.row.status}}</span>
              <span
                v-else-if="scope.row.status == '发明人确认定稿中'"
                class="font_finalization"
              >{{scope.row.status}}</span>
              <span
                v-else-if="scope.row.status == '文件格式审核中'"
                class="font_format"
              >{{scope.row.status}}</span>
              <span v-else>{{ scope.row.status }}</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          v-if="checked4"
          prop="type"
          label="专利类型"
          min-width="130"
          align="left"
          sortable="custom"
        >
          <template slot-scope="scope">
            <div class="more">{{scope.row.type}}</div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          v-if="checked3"
          prop="patent_name"
          label="专利名称"
          min-width="150"
          align="left"
          sortable="custom"
        >
          <template slot-scope="scope">
            <div class="more">{{scope.row.patent_name}}</div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          v-if="checked1"
          prop="patent_user"
          label="专利权人"
          min-width="130"
          align="left"
          sortable="custom"
        >
          <template slot-scope="scope">
            <div class="more">{{scope.row.patent_user}}</div>
          </template>
        </el-table-column>

        <el-table-column
          show-overflow-tooltip
          v-if="checked2"
          prop="user_name"
          label="发明人"
          min-width="130"
          align="left"
          sortable="custom"
        >
          <template slot-scope="scope">
            <div class="more">{{scope.row.user_name}}</div>
          </template>
        </el-table-column>
        <el-table-column
          v-if="checked9"
          prop="process_id"
          label="专属顾问"
          min-width="130"
          align="left"
          sortable="custom"
        >
          <template slot-scope="scope">
            <div class="more">
              <span
                style="margin-right: 10px"
                v-if="scope.row.process && scope.row.process.email_work"
              >{{ scope.row.process.email_work.split("@")[0].split("followup")[1] }}</span>
              <Tooltip v-if="scope.row.process" content="点我留言">
                <i class="el-icon-chat-dot-round leaveWord" @click="leaveWord(scope.row)"></i>
              </Tooltip>
            </div>
          </template>
        </el-table-column>
        <el-table-column
          v-if="checked5"
          prop="agent_id"
          label="代理人"
          min-width="130"
          align="left"
          sortable="custom"
        >
          <template slot-scope="scope">
            <div class="more">
              <span v-if="scope.row.agent">{{ scope.row.agent | agentNumber }}</span>
              <Tooltip v-if="scope.row.agent" content="点我留言">
                <i class="el-icon-chat-dot-round leaveWord" @click="leaveWordD(scope.row)"></i>
              </Tooltip>
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          v-if="checked8"
          prop="created_at"
          label="提交时间"
          sortable
          min-width="180"
          align="left"
        >
          <template slot-scope="scope">
            <div class="more">{{scope.row.created_at}}</div>
          </template>
        </el-table-column>

        <el-table-column :fixed="isFixed" width="100" align="center" v-if="checked99">
          <template slot="header">
            <span class="tableLastCol">操作</span>
          </template>

          <template slot-scope="scope">
            <el-button
              v-if="softConfirm"
              size="mini"
              type="danger"
              @click.stop="reminders(scope.row.id, scope.row, scope.$index)"
              :disabled="!(scope.row.status == '发明人确认定稿中')"
            >确认</el-button>
            <el-button
              v-else
              size="mini"
              type="danger"
              @click.stop="remindersConfirm(scope.row.id, scope.row, scope.$index)"
              :disabled="!(scope.row.remind_count < 3 && getRemindTime(scope.row.remind_at, scope.row.created_at, scope.row.status)) || !(scope.row.status == '代理人撰写中' || scope.row.status == '待接单')"
            >催单</el-button>
            <!-- <el-button size="mini" type="danger" @click.stop="getRemindTime(scope.row.remind_at)">催单</el-button> -->
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        class="pagination"
        background
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="pageSizes"
        :page-size="Number(pageSize)"
        layout="total, prev, pager, next, jumper"
        :total="total"
      ></el-pagination>

      <!-- 查看订单弹出框 -->
      <el-dialog
        @open="openLook"
        :modal="false"
        center
        :visible.sync="$store.state.lookOrder"
        class="lookOrder"
        :destroy-on-close="true"
        @close="closeLook"
      >
        <el-row :gutter="24">
          <el-col :span="24">
            <el-steps
              :active="opDateMax"
              class="steps"
              align-center
              finish-status="success"
              process-status="success"
            >
              <el-step v-for="(item,index) in stepsText" :title="item" description :key="index"></el-step>
            </el-steps>
            <br />
            <div class="lookOrder-right-collapse">
              <el-collapse accordion v-if="showOP">
                <el-collapse-item title="流程进度" name="1">
                  <Timeline class="steps" style="padding: 10px 0 0 0;">
                    <template v-for="(item, index) in opData"> 
                      <template>
                        <span class="time_line" v-if="index*1 < opData.length-1">
                          耗时：{{intervalTime(opData[index*1+1].pivot.created_at,opData[index*1].pivot.created_at)}}
                        </span>
                      </template>
                      <Timeline-item color="blue" :key="index">
                        <span class="process-time">{{ item.pivot.created_at }}</span>
                        <br />{{ item.name }}
                      </Timeline-item>
                      <!-- <Timeline-item color="blue" v-if="item.id==14" :key="index">
                        <span class="process-time">{{ item.pivot.created_at }}</span>
                        <br />案件已撤案
                      </Timeline-item>-->
                    </template>
                  </Timeline>
                </el-collapse-item>
                <el-collapse-item title="订单详情" name="2">
                  <el-form
                    :model="orderDetails"
                    ref="lookorderDialog"
                    label-min-width="120px"
                    class="lookeOerderFrom"
                  >
                    <el-row type="flex">
                      <el-col :span="24">
                        <el-form-item style="border-bottom: 0;" label="专利名称：">{{ orderDetails.patent_name }}</el-form-item>
                      </el-col>
                    </el-row>
                    <el-row type="flex">
                      <el-col :span="12">
                        <el-form-item label="专利类型：">{{ orderDetails.type }}</el-form-item>
                      </el-col>
                      <el-col :span="12">
                        <el-form-item label="订单编号：">{{ orderDetails.order_number }}</el-form-item>
                      </el-col>
                    </el-row>
                    <el-row type="flex">
                      <el-col :span="12">
                        <el-form-item label="状态：">
                          <span class="fontgreen">{{ orderDetails.status }}</span>
                        </el-form-item>
                      </el-col>
                      <el-col :span="12">
                        <el-form-item label="代理人：">
                          <span
                            class="fontgreen"
                            v-if="orderDetails.agent"
                          >{{ orderDetails.agent.email_work ? orderDetails.agent.email_work.split("@")[0].slice(-3) : '-' }}号</span>
                          <span v-else></span>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row type="flex">
                      <el-col :span="12">
                        <el-form-item label="专属顾问：">
                          <span
                            class="fontgreen"
                            v-if="orderDetails.process"
                          >{{ orderDetails.process.email_work.split("@")[0].split("followup")[1] + '号' }}</span>
                          <span v-else></span>
                        </el-form-item>
                      </el-col>
                      <el-col :span="12">
                        <el-form-item label="专利权人：">{{ orderDetails.patent_user }}</el-form-item>
                      </el-col>
                    </el-row>
                    <el-row type="flex">
                      <el-col :span="12">
                        <el-form-item label="发明人：">{{ orderDetails.user_name }}</el-form-item>
                      </el-col>
                      <el-col :span="12">
                        <el-form-item label="身份证号：">{{ orderDetails.id_card }}</el-form-item>
                      </el-col>
                    </el-row>
                    <el-row type="flex">
                      <el-col :span="6">
                        <el-form-item style="border-bottom: 0;" label="联络人：">{{ orderDetails.liaisons }}</el-form-item>
                      </el-col>
                      <el-col :span="10">
                        <el-form-item style="border-bottom: 0;" label="联络人邮箱：">{{ orderDetails.liaisons_email }}</el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item style="border-bottom: 0;" label="联络人电话：">{{ orderDetails.liaisons_tel }}</el-form-item>
                      </el-col>
                    </el-row>
                    <el-form-item class="mr0" style="border-bottom: 0;" label="技术领域：">{{ orderDetails.territory }}</el-form-item>
                    <el-form-item class="mr0" style="border-bottom: 0;" label="技术背景：">{{ orderDetails.background }}</el-form-item>
                    <el-form-item class="mr0" style="border-bottom: 0;" label="技术问题：">{{ orderDetails.problem }}</el-form-item>
                    <el-form-item style="border-bottom: 0;" class="mr0" label="技术方案：">{{ orderDetails.plan }}</el-form-item>
                    <el-form-item class="mr0" style="border-bottom: 0;" label="项目优势：">{{ orderDetails.advantage }}</el-form-item>
                    <el-form-item class="mr0" label="具体实施方式：">{{ orderDetails.way }}</el-form-item>
                    <el-row type="flex">
                      <el-col :span="12">
                        <el-form-item label="附图：">
                          <!-- <div v-if="orderDetails.img" class="file-box preview-img-wrap">
                            <el-image
                              v-for="(item, index) in orderDetails.img_arr"
                              :key="index"
                              :src="item"
                              :preview-src-list="orderDetails.img_arr"
                            ></el-image>
                          </div> -->
                          <div v-if="orderDetails.img != '' || orderDetails.img != null" class="preview-img-wrap">
                            <pre-img
                              :smallImg="orderDetails.imgList" 
                              :bigImg="orderDetails.imgList2"
                              class="pre-img">
                            </pre-img>
                          </div>
                        </el-form-item>
                      </el-col>
                      <el-col :span="12">
                        <el-form-item label="附件：">
                          <div class="file-box" v-if="orderDetails.file">
                            <a
                              v-for="item in orderDetails.fileArr"
                              :key="item.id"
                              :href="baseUrl + '/api/download?path='  + item.file +'/'+ item.path"
                              :download="item.path"
                              :title="item.path"
                              class="file_download"
                            ></a>
                          </div>
                        </el-form-item>
                      </el-col>
                    </el-row>

                    <el-form-item class="mr0 clearfloat" label="定稿文件：">
                      <div class="file-box" v-if="orderDetails.fishArr">
                        <a
                          v-for="item in orderDetails.fishArr"
                          :key="item.id"
                          :href="baseUrl + '/api/download?path='  + item.file +'/'+ item.path"
                          :download="item.path"
                          :title="item.path"
                          class="file_download"
                        ></a>
                        <!-- <a class="el-icon-picture-outline file_sh" :href="baseUrl + '/api/download?path=' + '/' + orderDetails.file"
                        :download="orderDetails.file" :title="orderDetails.file"></a>-->
                      </div>
                      <div
                        v-if="orderDetails.fishArr && orderDetails.status == '发明人确认定稿中'"
                        class="file-btns"
                      >
                        <!-- {{ orderDetails }} -->
                        <el-button
                          v-no-more-click:3000
                          size="mini"
                          type="primary"
                          @click="confirmFishFile('confirm', orderDetails.id,orderDetails)"
                        >确认定稿</el-button>
                        <el-button
                          v-no-more-click:3000
                          size="mini"
                          type="danger"
                          @click="confirmFishFile('back', orderDetails.id,orderDetails)"
                        >退回定稿</el-button>
                      </div>
                    </el-form-item>
                    <el-row v-if="orderDetails.grades">
                      <el-col :span="12">
                        <el-form-item
                          label="服务态度："
                          style="border-bottom-width: 1px;"
                          class="flex-form"
                        >
                          <el-rate
                            disabled
                            show-score
                            allow-half
                            v-model="orderDetails.grades.attitude"
                          ></el-rate>
                        </el-form-item>
                      </el-col>
                      <el-col :span="12">
                        <el-form-item
                          label="撰写质量："
                          style="border-bottom-width: 1px;"
                          class="flex-form"
                        >
                          <el-rate
                            disabled
                            show-score
                            allow-half
                            v-model="orderDetails.grades.quelity"
                          ></el-rate>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row v-if="orderDetails.grades">
                      <el-col :span="24">
                        <el-form-item
                          label="撰写耗时"
                          style="border-bottom-width: 1px;"
                          class="flex-form"
                        >
                          <el-rate
                            disabled
                            show-score
                            allow-half
                            v-model="orderDetails.grades.take_time"
                          ></el-rate>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row v-if="orderDetails.grades">
                      <el-col :span="24">
                        <el-form-item
                          label="评价："
                          style="border-bottom-width: 1px;"
                        >{{orderDetails.grades.remark}}</el-form-item>
                      </el-col>
                    </el-row>
                    <el-row type="flex" justify="center" class="mt10">
                      <template v-if="orderDetails.status == '上报文件上传中'">
                        <el-button
                          v-if="orderDetails.is_grades == 0"
                          type="success"
                          size="small"
                          @click="agentRate(orderDetails)"
                          :disabled="orderDetails.is_grades != 0"
                        >案件评分</el-button>
                        <template v-if="orderDetails.grades">
                          <el-button
                            v-if="orderDetails.grades.remark == '' "
                            class="ml10"
                            type="success"
                            size="small"
                            @click="additionalRate(orderDetails)"
                          >追加评论</el-button>
                        </template>
                        <el-button
                          v-if="orderDetails.grades && orderDetails.grades.total_score / 3 >= 4.5"
                          type="primary"
                          size="small"
                          @click="reward(orderDetails)"
                        >打赏</el-button>
                      </template>

                      <!-- <el-button class="ml10" type="success" size="small" @click="additionalRate(orderDetails)">追加评论
                      </el-button>-->
                      <!-- <el-button
                        v-if="orderDetails.is_distribution == 3 && orderDetails.order_number.slice(0, 2) == 'ZY'"
                        :disabled="order_pay && order_pay.pay_status != 2"
                        type="warning"
                        size="small"
                        @click.stop="goPay(orderDetails)"
                      >去支付</el-button> -->
                    </el-row>
                  </el-form>
                </el-collapse-item>
              </el-collapse>
            </div>
          </el-col>
        </el-row>
      </el-dialog>

      <!-- 留言框 -->
      <el-dialog
        title="留言"
        :visible.sync="showRefund4"
        center
        @close="leaveWordClose"
        class="leaveWordDialog"
      >
        <span class="leaveWord-label">请输入你的留言</span>
        <el-input type="textarea" v-model="leaveWordText"></el-input>
        <span slot="footer" class="dialog-footer">
          <el-button v-no-more-click:3000 type="warning" size="small" @click="cancel">取消</el-button>
          <el-button
            v-no-more-click:3000
            @click="submitLeaveWord"
            type="primary"
            size="small"
            :loading="isLeaveWord"
          >确定</el-button>
        </span>
      </el-dialog>

      <!-- 信息提示框 -->
      <promptMessage ref="promptMessage" @getData="search1" @agentRate="agentRate" />

      <!-- 评分 -->
      <rate ref="rate" @refresh="refresh"></rate>

      <!-- 追加评分 -->
      <additionalRate ref="additionalRate" @refresh="refresh" :type="2"></additionalRate>

      <!-- 打赏 -->
      <reward ref="reward" @refresh="refresh"></reward>
    </div>
  </div>
</template>

<script>
import preImg from '~/components/pre-img'
import { timeout } from "q";
import promptMessage from "~/components/promptMessage";
import rate from "~/components/rate";
import additionalRate from "~/components/additionalRate";
import fncSearch from "~/components/searchSrceen/fnc-search.js";
import moment from "moment";
import { getMyInfo } from "~/api/user";
import { sendPrivateLetter } from "~/util/index";
import reward from "../components/reward";
import {intervalTime} from '~/util'
export default {
  data() {
    return {
      finals_id:'',
      order_id:'',
      timeInterval: [],
      softConfirm: false,
      table_show: true,
      checked: true,
      checked0: true,
      checked1: true,
      checked2: true,
      checked3: true,
      checked4: true,
      checked5: true,
      checked6: true,
      checked7: true,
      checked8: true,
      checked9: true,
      checked99: true,
      loading: true,
      tableData: [],
      pageSizes: [25, 50],
      pageSize: 25,
      tableSize: 10, //一页几条
      tableStart: 0, //table数组过滤的第一条索引
      tableEnd: 10, //table数组过滤的最后一条索引
      currentPage: 1, //目前在第几页
      showOP: false,
      opData: [],
      opDateMax: 0, //状态里最大的id是多少
      stepsText: [
        "提交申请",
        "代理人接单",
        "案件撰写",
        "案件质控",
        "发送定稿文件",
        "发明人定稿",
        "案件上传",
        "递交国知局"
      ],
      routeid: "orderInProcess",
      orderNumber: "",

      showRefund4: false,
      refundID: "",
      refundIndex: "",
      isFixed: "right",
      order_number: "",
      lastTime: 0,
      total: 0,
      order: {},
      orderDetails: {},
      leaveWordText: "",
      leaveWordId: "",
      //附图图片
      imgArr: [],
      //附件文件
      fileArr: [],
      // 定稿文件
      fishArr: [],
      baseUrl: global.baseurl,
      showFilter: false, // 控制显示筛选条件
      showFilterCondition: false,
      conditionForm: {
        condition: []
      }, //筛选条件
      columns: [
        {
          label: "订单编号",
          id: 3,
          parameter: "order_number"
        },
        {
          label: "订单状态",
          id: 1,
          parameter: "status"
        },
        {
          label: "专利类型",
          id: 10,
          parameter: "type"
        },
        {
          label: "专利名称",
          id: 2,
          parameter: "patent_name"
        },
        {
          label: "专利权人",
          id: 12,
          parameter: "patent_user"
        },
        {
          label: "发明人",
          id: 13,
          parameter: "user_name"
        },
        {
          label: "专属顾问",
          id: 5,
          parameter: "process_id"
        },
        {
          label: "代理人",
          id: 9,
          parameter: "agent_id"
        },
        {
          label: "提交时间",
          id: 15,
          parameter: "subimt_time"
        }
      ],
      searchValue: "",
      submitTime: [],
      agentOptions: [],
      processOptions: [],
      LorD: "",
      tableSelectRow: {},
      leaveWordEmail: "",
      leaveWordData: {},
      paramsByOrder: {
        status:
          "待接单,代理人撰写中,案件内审中,案件修改中,定稿文件发送中,发明人确认定稿中,上报文件上传中,文件格式审核中"
      },
      sortQuery: {},
      userData: {},
      isLeaveWord: false,
      replyMessage: "",
      privateLetterId: null
    };
  },
  created() {
    this.getData();
    this.getUserData();
    this.getMyinfo();
  },
  computed: {
    selectArr() {
      let arr = [
        this.checked0,
        this.checked1,
        this.checked2,
        this.checked3,
        this.checked4,
        this.checked5,
        this.checked6,
        this.checked8,
        this.checked9
      ];
      return arr;
    }
  },
  components: {
    promptMessage,
    fncSearch,
    rate,
    reward,
    additionalRate,
    preImg
  },
  methods: {
    toSoftware(){
      this.$router.push('/user/myApply/software')
    },
    // 计算时间间隔
    intervalTime(startTime,endTime){
      var date1 = new Date(startTime); //开始时间
      var date2 = new Date(endTime); //结束时间
      var date3 = date2.getTime() - date1.getTime(); //时间差的毫秒数
      //计算出相差天数
      var days = (date3 / (24 * 3600 * 1000)).toFixed(1)
      //计算出小时数

      var leave1 = date3 % (24 * 3600 * 1000); //计算天数后剩余的毫秒数
      var hours = (leave1 / (3600 * 1000)).toFixed(1)
      //计算相差分钟数
      var leave2 = leave1 % (3600 * 1000); //计算小时数后剩余的毫秒数
      var minutes = (leave2 / (60 * 1000)).toFixed(1)

      //计算相差秒数

      var leave3 = leave2 % (60 * 1000); //计算分钟数后剩余的毫秒数
      var seconds = Math.round(leave3 / 1000);
      // return days + "天 " + hours + "小时 " + minutes + "分钟" + seconds + " 秒";

      if (days > 0) {
        return days + '天'
      } else {
        if (hours > 0) {
          return hours + "时"
          // return (hours/24).toFixed(1) + '天'
          // } else if(minutes < 1) {
          //   return '少于1分钟'
        } else{
          return minutes + "分"
        }
      }
    },
    goPay(data) {
      this.$router.replace({
        name: "payment",
        query: {
          order: data.order.id,
          from: this.$route.path
        }
      });
    },
    additionalRate(data) {
      let order = {
        id: data.id,
        grades: data.grades
      };
      this.$alert("该评价信息为匿名评价，代理人不可见", "提示", {
        confirmButtonText: "确定",
        callback: action => {
          this.$refs["additionalRate"].show(order);
        }
      });
    },
    reward(data) {
      this.$refs["reward"].show(data);
    },
    async getMyinfo(params) {
      let myInfo = await getMyInfo(this.$axios, params);
      if (myInfo.data.status == "success") {
        this.$store.commit("setRoleInfo", myInfo.data.data);
        this.$store.commit("setUser", myInfo.data.data);
        this.myInfo = myInfo.data.data;
        this.roleID = this.myInfo.role_id;
      }
    },
    refresh() {
      this.$store.commit("setLookOrder", false);
      this.search1();
    },
    agentRate(data) {
      this.$refs["rate"].showOn(data);
    },
    gwm() {
      //水印,非管理员要设置
      if (
        this.$store.state.user.role_id != 1 &&
        this.$route.path != "/admin/register" &&
        this.$route.path != "/admin/personalCenter/dstribution" &&
        this.$route.path != "/admin/personalCenter/myPurse" &&
        this.$route.path != "/admin/activityList/activityConfig" &&
        this.$route.path != "/admin/activityList/sysConfig" &&
        this.$route.path != "/admin/login" &&
        this.$route.path != "/admin/agentImprove" &&
        this.$route.path != "/order/login"
      ) {
        let that = this;
        let gwm = require("gwm");
        gwm.creation({
          txt: that.$store.state.user.name,
          container: ".el-table", //#gwm
          fontSize: 40
        });
      }
    },
    allChange(val) {
      if (val) {
        this.checked0 = true;
        this.checked1 = true;
        this.checked2 = true;
        this.checked3 = true;
        this.checked4 = true;
        this.checked5 = true;
        this.checked6 = true;
        this.checked7 = true;
        this.checked8 = true;
        this.checked9 = true;
      } else {
        this.checked0 = false;
        this.checked1 = false;
        this.checked2 = false;
        this.checked3 = false;
        this.checked4 = false;
        this.checked5 = false;
        this.checked8 = false;
        this.checked7 = false;
        this.checked6 = false;
        this.checked9 = false;
      }
    },
    // 获取用户信息
    getUserData() {
      this.$axios.get("/api/consumer/show").then(res => {
        if (res.data.code == "200") {
          this.userData = res.data.data;
        }
      });
    },
    getData(pPage) {
      let that = this;
      //我的订单列表
      that.$axios
        .get("/api/consumer/order", {
          params: {
            status:
              "待接单,代理人撰写中,案件内审中,案件修改中,定稿文件发送中,发明人确认定稿中,上报文件上传中,文件格式审核中",
            page: pPage,
            sort_str: "created_at",
            sort_order: "desc"
          }
        })
        .then(res => {
          that.loading = false;
          that.tableData = res.data.data;
          that.pageSize = res.data.page.per_page;
          that.tableSize = res.data.page.per_page;
          that.tableEnd = res.data.page.per_page;
          that.total = res.data.page.total;

          // 重绘表格解决错位问题
          this.$nextTick(() => {
            this.$refs.orderTb.doLayout();
          });
        });
    },

    //选择一页几条
    handleSizeChange(size) {
      this.paramsByOrder.perPage = size;
      this.paramsByOrder.page = 1;
      this.$axios
        .get("/api/consumer/order", {
          params: this.paramsByOrder
        })
        .then(res => {
          this.tableData = res.data.data;
          this.pageSize = res.data.page.per_page;
          this.tableSize = res.data.page.per_page;
          this.tableEnd = res.data.page.per_page;
          this.total = res.data.page.total;
        });
    },
    // 图片， 文件 分组
    imgs(data) {
      if (data.img == null || data.img == "") {
      } else {
        let img_Arr = data.img.split("&");
        data.imgArr = [];
        data.img_arr = [];
        for (const i in img_Arr) {
          let itemobj = {
            id: i + 1,
            path: img_Arr[i],
            file: ""
          };
          let img = this.baseUrl + "/storage/upload/" + img_Arr[i];
          data.img_arr.push(img);
          let itemArr = itemobj.path.split("/");
          itemobj.path = itemArr[itemArr.length - 1];
          itemobj.file = itemArr.slice(0, 2).join("/");
          data.imgArr.push(itemobj);
        }
      }
      //文件 切分组件
      if (data.file == null || data.file == "") {
      } else {
        let file_Arr = data.file.split("&");
        data.fileArr = [];
        for (const i in file_Arr) {
          let itemobj = {
            id: i + 1,
            path: file_Arr[i],
            file: ""
          };
          let itemArr = itemobj.path.split("/");
          itemobj.path = itemArr[itemArr.length - 1];
          itemobj.file = itemArr.slice(0, 2).join("/");
          data.fileArr.push(itemobj);
        }
      }

      if (data.confirm_file == null || data.confirm_file == "") {
      } else {
        let fish_Arr = data.confirm_file.split("&");
        data.fishArr = [];
        for (const i in fish_Arr) {
          let itemobj = {
            id: i + 1,
            path: fish_Arr[i],
            file: ""
          };
          let itemArr = itemobj.path.split("/");
          itemobj.path = itemArr[itemArr.length - 1];
          itemobj.file = itemArr.slice(0, 2).join("/");
          data.fishArr.push(itemobj);
        }
      }
      if (data.review_file == null || data.review_file == "") {
      } else {
        let fish_Arr = data.review_file.split("&");
        data.reviewFile = [];
        for (const i in fish_Arr) {
          let itemobj = {
            id: i + 1,
            path: fish_Arr[i],
            file: ""
          };
          let itemArr = itemobj.path.split("/");
          itemobj.path = itemArr[itemArr.length - 1];
          itemobj.file = itemArr.slice(0, 2).join("/");
          data.reviewFile.push(itemobj);
        }
      }
    },
    //获取所有代理人
    getAllAgent() {
      this.$axios
        .get("api/user/agent/all")
        .then(res => {
          if (res.data.code == 200) {
            this.agentOptions = res.data.data;
          }
        })
        .catch(err => {
          this.$message({
            type: "err",
            message: err
          });
        });

      this.$axios
        .get("api/user/process")
        .then(res => {
          if (res.data.code == 200) {
            this.processOptions = res.data.data;
          }
        })
        .catch(err => {
          this.$message({
            type: "err",
            message: err
          });
        });
    },

    handleCurrentChange(val) {
      this.paramsByOrder.page = val;
      let that = this;
      let params = this.paramsByOrder;
      that.$axios
        .get("/api/consumer/order?page=" + val, {
          params
        })
        .then(res => {
          that.loading = false;
          // console.log(res.data)
          that.tableData = res.data.data;
          this.pageSize = res.data.page.per_page;
          this.tableSize = res.data.page.per_page;
          this.tableEnd = res.data.page.per_page;
          this.total = res.data.page.total;
        });
    },

    // 订单详情
    selectRow(row, column, event) {
      this.$store.commit("setLookOrder", true)
      let params = {
        order:row.id
      }
      this.$axios.get(`api/order/${row.id}`,{
        params: params
      }).then(res => {
        if (res.data.code == 200) {
          this.orderDetails = res.data.data;
          this.interceptFile(res.data.data)
          this.tableSelectRow = row;
          if (window.getSelection().toString() === "") {
            // this.orderDetails = row;
            // 案件评分，获得number类型
            if (this.orderDetails.grades) {
              this.orderDetails.grades.attitude = Number(
                this.orderDetails.grades.attitude
              );
              this.orderDetails.grades.take_time = Number(
                this.orderDetails.grades.take_time
              );
              this.orderDetails.grades.quelity = Number(
                this.orderDetails.grades.quelity
              );
            }
            this.imgs(this.orderDetails);
            this.order = row;
            let opData = [];
            opData.push(...row.statuss);
            let firstInternalAudit = null;
            let lastInternalAudit = null;
            let lastForYes = null;
            let lastForNo = null;
            var firstDate = "";
            // 拿第一次审计
            for (let i = 0; i < opData.length; i++) {
              if (opData[i].id == 3) {
                firstInternalAudit = opData[i];
                firstDate = new Date(
                  firstInternalAudit.pivot.created_at.replace(/-/g, "/")
                ).getTime();
              }
            }

            // 拿最后一次是审核通过或者是不通过
            for (let i = 0; i < opData.length; i++) {
              if (opData[i].id == 4) {
                lastForYes = opData[i];
                break;
              }
            }
            for (let i = 0; i < opData.length; i++) {
              if (opData[i].id == 5) {
                lastForNo = opData[i];
                break;
              }
            }
            let lastForYesTime = 0;
            if (lastForYes) {
              lastForYesTime = new Date(
                lastForYes.pivot.created_at.replace(/-/g, "/")
              ).getTime();
            }
            let lastForNoTime = 0;
            if (lastForNo) {
              lastForNoTime = new Date(
                lastForNo.pivot.created_at.replace(/-/g, "/")
              ).getTime();
            }
            // 去除除第一次审核和最后一次审核外的其他审核流程
            let spliceArrays = [];

            for (let i = 0; i < opData.length; i++) {
              if (firstInternalAudit) {
                if (opData[i].id == 3) {
                  let itemTime = new Date(
                    opData[i].pivot.created_at.replace(/-/g, "/")
                  ).getTime();
                  if (firstDate != itemTime) {
                    spliceArrays.push(i);
                  }
                }
              }
            }

            for (let i = 0; i < opData.length; i++) {
              if (firstInternalAudit) {
                if (opData[i].id == 3) {
                  let itemTime = new Date(
                    opData[i].pivot.created_at.replace(/-/g, "/")
                  ).getTime();
                  if (firstDate != itemTime) {
                    spliceArrays.push(i);
                  }
                }
              }

              if (lastForYes) {
                let lastForYesDate = lastForYes.pivot.created_at;
                if (opData[i].id == 4) {
                  if (
                    lastForYesDate == opData[i].pivot.created_at &&
                    lastForYesTime > lastForNoTime
                  ) {
                    continue;
                  } else {
                    opData.splice(i, 1);
                  }
                }
              }

              if (lastForNo) {
                let lastForNoDate = lastForNo.pivot.created_at;
                if (opData[i].id == 5) {
                  if (
                    lastForNoDate == opData[i].pivot.created_at &&
                    lastForNoTime > lastForYesTime
                  ) {
                    continue;
                  } else {
                    opData.splice(i, 1);
                  }
                }
              }
            }

            for (let i = 0; i < spliceArrays.length; i++) {
              opData.splice(spliceArrays[i], 1);
            }
            this.opData = [];
            this.opData.push(...opData);
            let opData2Temp = [];

            for (let i in row.statuss) {
              let obj = {
                id: row.statuss[i].id,
                name: row.statuss[i].name,
                created_at: row.statuss[i].created_at
              };
              let pivot = {};
              for (let m in row.statuss[i].pivot) {
                pivot[m] = row.statuss[i].pivot[m];
              }
              obj.pivot = pivot;
              opData2Temp.push(obj);
            }

            //②opData数组按每个元素的“id”属性升序
            let opData2 = [];
            opData2.push(...opData2Temp);
            opData2.reverse();

            let opDateMax = opData2.length - 1;
            for (let i = opDateMax; i >= 0; i--) {
              if (opData2[i].id == 8) {
                this.opDateMax = 8;
                break;
              } else if (opData2[i].id == 7) {
                this.opDateMax = 7;
                break;
              } else if (opData2[i].id == 13) {
                this.opDateMax = 6;
                break;
              } else if (opData2[i].id == 10) {
                this.opDateMax = 5;
                break;
              } else if (opData2[i].id == 4) {
                this.opDateMax = 4;
                break;
              } else if (opData2[i].id == 3) {
                this.opDateMax = 3;
                break;
              } else if (opData2[i].id == 2) {
                this.opDateMax = 2;
                break;
              } else if (opData2[i].id == 1) {
                this.opDateMax = 0;
                break;
              }
            }
            this.showOP = true;
            this.$store.commit("setLookOrder", true);
          }
        }
      })
      
    },
    interceptFile (data) {
      //图片 切分组件
      if (data.thumb_imgs == null || data.thumb_imgs == "") {} else {
        let img_Arr = data.thumb_imgs.split("&");
        let img_Arr2 = data.img.split('&')
        data.imgArr = [];
        data.imgList = [];
        data.imgList2 = []
        for (const i in img_Arr2) {
          data.imgList2.push(global.baseurl + '/storage/upload/' + img_Arr2[i])
        }
        for (const i in img_Arr) {
          let itemobj = {
            id: i + 1,
            path: img_Arr[i],
            file: ''
          };
          data.imgList.push(global.baseurl + '/storage/upload/' + img_Arr[i])
          let itemArr = itemobj.path.split("/")
          itemobj.path = itemArr[itemArr.length - 1]
          itemobj.file = itemArr.slice(0, 2).join("/");
          data.imgArr.push(itemobj);
        }
      }
    },
    leaveWord(row) {
      if (row.finals_id) {
        this.finals_id = row.finals_id
      } else {
        this.order_id = row.id
      }
      this.showRefund4 = true;
      this.$store.commit("setLookOrder", false);
      this.leaveWordId = row.id;
      this.LorD = "专属顾问";
      this.leaveWordEmail = row.process.email_work;
      this.leaveWordData = row; 
      this.privateLetterId = row.process.id;
    },
    leaveWordD(row) {
      if (row.finals_id) {
        this.finals_id = row.finals_id
      } else {
        this.order_id = row.id
      }
      this.showRefund4 = true;
      // this.showRefund3 = false;
      this.$store.commit("setLookOrder", false);
      this.leaveWordData = row;
      this.leaveWordId = row.agent_id;
      this.privateLetterId = row.agent_id;
    },
    openLook(row) {
      if (this.showRefund4) {
        this.$store.commit("setLookOrder", false);
      }
    },
    closeLook() {
    },
    quit(data){
      this.$router.push({
        path: '/user/news/caseExchange',
        query:{
          data:JSON.stringify(data)//对象转为字符串
        }
      });
    },
    submitLeaveWord() {
      let that = this;
      let params = {
          news: that.leaveWordText,
          receive_uid: that.privateLetterId
      }
      if (that.finals_id) {
        params.finals_id = that.finals_id
      } else {
        params.order_id = that.order_id
      }
      that.$axios.post('api/news/add_private_letter', params).then(res => {
        if (res.data.code == 200) {
          that.$message({
            type: 'success',
            message:"发送留言信息成功！"
          })
          that.showRefund4 = false;
          that.leaveWordText = ''
          setTimeout(() => {
            that.quit(res.data.data)
          }, 1000)
        }
      })
    },
    leaveWordClose() {
      this.leaveWordText = "";
      this.submitLeaveWordOrder = null;
    },
    addFilterCondition(item) {
      let filterItem = {
        value: "",
        label: item.label,
        parameter: item.parameter,
        key: Date.now()
      };
      if (this.conditionForm.condition.length > 0) {
        let conditionlabels = [];
        for (let i = 0; i < this.conditionForm.condition.length; i++) {
          conditionlabels.push(this.conditionForm.condition[i].label);
        }
        let Check = conditionlabels.indexOf(item.label);
        Check == -1
          ? this.conditionForm.condition.push(filterItem)
          : this.$message.error("请勿重复添加");
      } else {
        this.conditionForm.condition.push(filterItem);
      }

      this.showFilterCondition = false;
    },
    search1() {
      this.currentPage = 1;
      for (var i = 0; i < this.conditionForm.condition.length; i++) {
        let a = this.conditionForm.condition[i].parameter;
        this.paramsByOrder[a] = this.conditionForm.condition[i].value;

        if (this.conditionForm.condition[i].parameter === "subimt_time") {
          this.paramsByOrder.start_time = this.submitTime[0];
          this.paramsByOrder.end_time = this.submitTime[1];
        }
      }
      // 处理分页数据
      delete this.paramsByOrder.page;

      // 处理排序状态
      delete this.paramsByOrder.sort_str;
      delete this.paramsByOrder.sort_order;
      this.$refs["orderTb"].clearSort();
      if (!this.paramsByOrder.status) {
        this.paramsByOrder.status =
          "待接单,代理人撰写中,案件内审中,案件修改中,定稿文件发送中,发明人确认定稿中,上报文件上传中";
      }
      let that = this;
      //我的订单列表
      that.$axios
        .get("/api/consumer/order", {
          params: this.paramsByOrder
        })
        .then(res => {
          that.loading = false;
          that.tableData = res.data.data;
          this.pageSize = res.data.page.per_page;
          this.tableSize = res.data.page.per_page;
          this.tableEnd = res.data.page.per_page;
          this.total = res.data.page.total;
          this.showFilter = false;
        });

      // this.tableData = data.tableData
      // this.total = this.tableData.length
    },
    resetForm(formName) {
      // this.$refs.addnew.$refs.conditionForma.resetFields()
      this.$refs["orderTb"].clearSort();
      // this.conditionForm.condition = []
      this.conditionForm.condition.forEach(v => {
        if (v.value) {
          v.value = null;
        }
      });
      this.paramsByOrder = {
        status:
          "待接单,代理人撰写中,案件内审中,案件修改中,定稿文件发送中,发明人确认定稿中,上报文件上传中,文件格式审核中"
      };
      this.showFilterCondition = false;
      this.submitTime = [];
      this.$nextTick(() => {
        this.$refs[formName].clearValidate();
      });
      // this.showFilterCondition = false
      // this.getData()
      // this.showFilter = false
    },
    submitsearch(formName) {
      let that = this;
      this.$refs[formName].validate((valid, prop) => {
        // this.$refs[formName].clearValidate();
        let props = [];
        for (let k in prop) {
          props.push(prop[k][0].field);

          if ((prop[k][0].message = "提交时间不能为空")) {
            if (that.submitTime) {
              if (that.submitTime.length > 0) {
                that.$refs[formName].clearValidate([prop[k][0].field]);
                // that.search()
                let timeIndex = props.indexOf("提交时间不能为空");
                props.splice(timeIndex, 1);
              }
            } else {
              return false;
            }
          }
        }
        if (props.length) {
          that.$refs[formName].validateField(props, valid2 => {
            if (valid2) {
              return false;
            } else {
              that.search1();
            }
          });
        } else {
          that.search1();
        }
      });
    },
    removeDomain(item) {
      this.showFilter = true;
      delete this.paramsByOrder[item.parameter];
      let index = this.conditionForm.condition.indexOf(item);
      if (index !== -1) {
        this.conditionForm.condition[index] = [];
        this.conditionForm.condition.splice(index, 1);
      }

      if (item.label === "提交时间") {
        this.submitTime = [];
        delete this.paramsByOrder.start_time;
        delete this.paramsByOrder.end_time;
      }
      this.search1();
    },
    remindersConfirm(id, row) {
      this.$confirm('您确定要进行催单吗?', '催单提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
      }).then(() => {
        let that = this;
        let email,
          agentName = "";
        let isProcess = true;
        if (row.agent) {
          agentName = row.agent.name;
        }
        if (row.status === "待接单") {
          email = row.process.email_work;
        } else {
          email = row.agent.email_work;
          isProcess = false;
        }
        this.$axios.get(`api/consumer/order/${id}/remind`).then(res => {
          if (res.data.code == 200) {
            if (isProcess) {
              let pData = {
                email: email,
                phone: row.process.phone,
                number: email.split("@")[0].split("followup")[1],
                userName: this.$store.state.user.name
              };
              this.$refs["promptMessage"].showDialog("processUrging", pData);
            } else {
              let pData = {
                email: email,
                phone: row.agent.phone,
                number: email.split("@")[0].slice(-3),
                userName: this.$store.state.user.name
              };
              this.$refs["promptMessage"].showDialog("agentUrging", pData);
            }
            that.search1();
          } else {
            this.$message.error(res.data.message);
          }
        });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消催单'
        });          
      });
    },
    reminders(id, pData) {
      this.$axios.get(`api/order/${id}/web/confirm/file`).then(res => {
        if (res.data.code == "200") {
          let showMessageData = {
            order_id: id,
            agentPhone: pData.agent.phone,
            processPhone: pData.process.phone,
            agentNumber: pData.agent.email_work.split("@")[0].slice(-3),
            processNumber: pData.process.email_work
              .split("@")[0]
              .split("followup")[1]
          };
          this.$refs["promptMessage"].showDialog(
            "confirmFishFile",
            showMessageData
          );
          this.getUserData();
        }
      });
    },
    getRemindTime(pTime, pCreatedTime, status) {
      // scope.row.remind_at, scope.row.created_at, scope.row.status
      let remindTime = pTime;
      let createdTime = pCreatedTime;

      let createdTimeM = new Date(createdTime).getTime();
      let nowTimeM = new Date().getTime();

      let missedOrderTime = Math.floor(
        (nowTimeM - createdTimeM) / 1000 / 60 / 60
      );

      if (missedOrderTime < 72) {
        return false;
      }
      if (remindTime) {
        remindTime, (createdTime = remindTime.replace(/-/g, "/"));
        let remindTimeM = new Date(remindTime).getTime();
        let createdTimeM = new Date(createdTimeM).getTime();
        let nowTimeM = new Date().getTime();
        // 每次催单间隔时间
        let hour = Math.floor((nowTimeM - remindTimeM) / 1000 / 60 / 60);
        if (hour > 72) {
          return true;
        } else {
          return false;
        }
      } else {
        return true;
      }
    },

    changInput() {
      this.$refs["conditionForm"].clearValidate();
    },

    cancel() {
      this.showRefund4 = false;
    },
    // 表格排序
    tableSortChange(column) {
      if (column.order === "descending") {
        this.paramsByOrder.sort_str = column.prop;
        this.paramsByOrder.sort_order = "desc";
      } else if (column.order === "ascending") {
        this.paramsByOrder.sort_str = column.prop;
        this.paramsByOrder.sort_order = "asc";
      } else {
        delete this.paramsByOrder.sort_str;
        delete this.paramsByOrder.sort_order;
      }
      this.loading = true;
      this.$axios
        .get("/api/consumer/order", {
          params: this.paramsByOrder
        })
        .then(res => {
          this.loading = false;
          this.tableData = res.data.data;
          this.pageSize = res.data.page.per_page;
          this.tableSize = res.data.page.per_page;
          this.tableEnd = res.data.page.per_page;
          this.total = res.data.page.total;
        });
    },
    // 发明人确认定稿中 tableData
    clickPrompt() {
      let that = this;
      that.loading = true;
      that.softConfirm = true;
      // this.paramsByOrder.status = '发明人确认定稿中'
      // this.paramsByOrder.page = 1
      this.paramsByOrder = {
        status: "发明人确认定稿中",
        page: 1
      };
      that.$axios
        .get("/api/consumer/order", {
          params: this.paramsByOrder
        })
        .then(res => {
          that.loading = false;
          that.tableData = res.data.data;
          that.pageSize = res.data.page.per_page;
          that.tableSize = res.data.page.per_page;
          that.tableEnd = res.data.page.per_page;
          that.total = res.data.page.total;
          that.showFilter = false;
        });
    },
    clickPatent() {
      let that = this;
      that.loading = true;
      that.softConfirm = false;
      // this.paramsByOrder.status = '发明人确认定稿中'
      // this.paramsByOrder.page = 1
      this.paramsByOrder = {
        status:
          "待接单,代理人撰写中,案件内审中,案件修改中,定稿文件发送中,发明人确认定稿中,上报文件上传中,文件格式审核中",
        page: 1
      };
      that.$axios
        .get("/api/consumer/order", {
          params: this.paramsByOrder
        })
        .then(res => {
          that.loading = false;
          that.tableData = res.data.data;
          that.pageSize = res.data.page.per_page;
          that.tableSize = res.data.page.per_page;
          that.tableEnd = res.data.page.per_page;
          that.total = res.data.page.total;
          that.showFilter = false;
        });
    },
    confirmFishFile(val, id, pData) {
      if (val == "confirm") {
        this.$axios.get(`api/order/${id}/web/confirm/file`).then(res => {
          if (res.data.code == "200") {
            let showMessageData = {
              order_id: id,
              agentPhone: pData.agent.phone,
              processPhone: pData.process.phone,
              agentNumber: pData.agent.email_work.split("@")[0].slice(-3),
              processNumber: pData.process.email_work
                .split("@")[0]
                .split("followup")[1]
            };
            this.$refs["promptMessage"].showDialog(
              "confirmFishFile",
              showMessageData
            );
            this.getUserData();
          }
        });
      } else {
        this.$prompt("请输入修改意见", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          inputPattern: /^[\s\S]*.*[^\s][\s\S]*$/,
          inputErrorMessage: "修改意见不能为空"
        })
          .then(({ value }) => {
            let data = {
              id: id,
              modification: value
            };
            this.$axios
              .get(`api/order/${id}/web/confirm/file`, {
                params: data
              })
              .then(res => {
                if (res.data.code == "200") {
                  let showMessageData = {
                    agentPhone: pData.agent.phone,
                    processPhone: pData.process.phone,
                    agentNumber: pData.agent.email_work.split("@")[0].slice(-3),
                    processNumber: pData.process.email_work
                      .split("@")[0]
                      .split("followup")[1]
                  };
                  this.$refs["promptMessage"].showDialog(
                    "confirmFishFileForNo",
                    showMessageData
                  );
                  this.getUserData();
                }
              });
          })
          .catch(() => {
            this.$message({
              type: "info",
              message: "取消退回"
            });
          });
      }
    },
    submit(item) {
      if (this.replyMessage == "") {
        this.$message({
          message: "请输入消息",
          type: "warning"
        });
      } else {
        this.submitPost(item);
      }
    },
    showTextarea(item, index) {
      for (let i = 0; i < this.orderDetails.customer_opinions.length; i++) {
        this.orderDetails.customer_opinions[i].show_input = false;
        if (i == index) {
          this.orderDetails.customer_opinions[i].show_input = true;
        }
      }
    },
    submitPost(data) {
      let params = {
        opinion_id: data.id,
        review: this.replyMessage,
        type: "inventor"
      };
      this.$axios
        .post(`/api/order/${data.order_id}/agent_message`, params)
        .then(res => {
          if (res.data.code == 200) {
            this.$message({
              type: "success",
              message: "回复成功！"
            });
            this.replyMessage = "";
            this.getData(this.currentPage);
            setTimeout(() => {
              this.$store.commit("setLookOrder", false);
            }, 300);
          } else {
            this.$message({
              type: "error",
              message: res.data.message
            });
          }
        })
        .catch(e => {
          console.log(e);
        });
    }
  },
  updated() {
    let noP = document.getElementsByClassName("no-padding");
    for (let i = 0; i < noP.length; i++) {
      if (noP[i].parentNode && noP[i].parentNode.parentNode) {
        noP[i].parentNode.parentNode.style.padding = 0;
      }
    }
  },
  //配合.el-table{width:99.9%!important;}防止筛选抖动
  beforeUpdate() {
    // this.$nextTick(() => {
    // 	this.$refs.orderTb.doLayout();
    // });
  },
  beforeRouteEnter(to, from, next) {
    next(vm => {
      // 通过 `vm` 访问组件实例
      if (vm.$store.state.user.first == 1) {
        let isFirst = window.localStorage.getItem("first");
        if (!isFirst) {
          let text = "";
          vm.$store.state.user.name
            ? (text = vm.$store.state.user.name)
            : (text = "用户");
          vm.$confirm(
            `尊敬的${text}，欢迎您使用信和红谷知识产权服务系统！您的初始密码为您手机号后6位，为了您的账号安全请您及时修改`,
            "温馨提示！",
            {
              confirmButtonText: "立即修改",
              cancelButtonText: "不修改",
              type: "warning"
            }
          )
            .then(() => {
              vm.$router.push({
                path: "/user/set/updatePwd"
              });
              window.localStorage.setItem("first", 2);
            })
            .catch(() => {
              vm.$alert(
                `尊敬的<span style="color: rgb(73, 150, 124)">${text}</span>，后续如需修改密码请前往<span style="color: rgb(73, 150, 124)"><a class='a' href='/user/set/updatePwd'> 个人中心 </a></span>进行操作。`,
                {
                  confirmButtonText: "已知晓",
                  dangerouslyUseHTMLString: true,
                  callback: () => {
                    window.localStorage.setItem("first", 2);
                  }
                }
              );
            });
        }
      }
    });
  },
  watch: {
    selectArr(val) {
      this.table_show = false;
      this.$nextTick(() => {
        this.table_show = true;
      });
      setTimeout(() => {
        this.$nextTick(() => {
          this.gwm();
        });
      }, 300);
      if (val.some(v => v == false)) {
        this.checked = false;
      } else {
        this.checked = true;
      }
      if (val.every(v => v == false)) {
        this.checked99 = false;
      } else {
        this.checked99 = true;
      }
    }
  }
};
</script>

<style lang='less'>
.files {
  width: 90%;
  height: 100%;
  margin: 0 auto;
  padding: 20px 30px 60px 30px;
  background: rgba(255, 255, 255, 1);
  box-sizing: border-box;
  &-header {
    height: 45px;
    float: left;
    .el-breadcrumb {
      .el-breadcrumb__item {
        .el-breadcrumb__inner,
        .el-breadcrumb__separator {
          font-size: 25px;
          color: rgba(0, 35, 151, 1);
          font-weight: 400;
        }
      }
      .el-breadcrumb__item:first-child {
        .el-breadcrumb__inner {
          padding-left: 10px;
          border-left: 5px solid #002397;
        }
      }
    }
  }
}
.process-time {
  color: #b4b4b4;
  font-size: 15px;
}
.el-checkbox__label {
  color: rgba(142, 142, 142, 1) !important;
}
//  订单状态
.font_waiting {
  color: rgba(255, 89, 89, 1);
}
.font_compose {
  color: rgba(255, 0, 0, 1);
}
.font_audit {
  color: rgba(255, 144, 0, 1);
}
.font_edit {
  color: rgba(208, 191, 0, 1);
}
.font_upload {
  color: rgba(0, 120, 255, 1);
}
.font_send {
  color: rgba(88, 185, 99, 1);
}
.font_finalization {
  color: rgba(130, 199, 214, 1);
}
.font_format {
  color: rgba(61, 2, 182, 1);
}
.flex-form {
  .el-form-item__content {
    height: 30px;
    display: flex;
    align-items: center;
  }
}
.myOrder {
  .clearfix:after {
    content: "";
    height: 0;
    display: block;
    clear: both;
  }
  .clearfix {
    zoom: 1;
  }
  .el-step__head.is-success {
    color: #fff;
    border-color: rgba(36, 157, 255, 1);
    .el-step__icon {
      background: rgba(36, 157, 255, 1);
      border-color: rgba(36, 157, 255, 1);
    }
    .el-step__line {
      background: rgba(36, 157, 255, 1);
    }
  }
  .el-step__title.is-success {
    color: rgba(85, 85, 85, 1);
  }
  .el-step__head {
    &.is-wait {
      .el-step__icon {
        &.is-text {
          .el-step__icon-inner {
            display: none; //不要序号
          }
        }
      }
    }
  }
  .ivu-timeline-item-content {
    font-size: 15px !important; //字体放大点
    top: -9px;
  }
  .ivu-timeline-item-tail {
    border-left: 2px dashed #e8eaec;
  }
  .ivu-timeline-item-head-blue {
    margin-left: 3px;
    width: 8px;
    height: 8px;
    background: #2d8cf0;
  }
  .el-range-separator {
    width: 60px;
  }

  .card {
    margin: 20px 0;
    clear: both;
  }
  .lookOrder {
    overflow-y: scroll;
    // .lookOrder-left {
    // 	float: left;
    // 	width: 50%;

    // }
    // .lookOrder-right {
    // 	padding: 28px 0 0 20px !important;
    // 	box-sizing: border-box;
    // 	.lookOrder-right-collapse {
    // 		padding-left: 20px;
    // 		// max-height: 270px;
    // 		// overflow-y: auto;
    // 	}
    // }
    .el-dialog {
      // min-width: 1500px ;
      width: 850px;
      // overflow-y: auto;
      // max-height: 100%;
      // overflow-x:;
      .el-dialog__body {
        padding: 50px;
        // margin-top: 50px;
      }
    }
    .textslineH {
      line-height: 25px !important;
    }
  }

  .search-input {
    width: 200px;
  }
  .leaveWordDialog {
    .el-dialog {
      width: 35%;
    }
    .leaveWord-label {
      display: block;
      margin-bottom: 10px;
    }
    .el-textarea {
      display: block;
      margin-bottom: 20px;
    }
  }
  .el-table {
    width: 99.9% !important;
    .el-table__header-wrapper {
      .has-gutter {
        .el-table__header {
          th:last-child {
            padding-right: 25px;
          }
        }
      }
    }
  }

  height: 100%; //撑满表格
  .hr {
    border: 1px solid #c5cfdb;
  }

  .steps {
    margin-left: 20px;
  }

  .center-title {
    color: rgb(240, 173, 78);
    font-weight: bold;
  }

  .center-title2 {
    color: rgb(23, 140, 223);
    font-weight: bold;
  }

  .center-title3 {
    color: rgb(217, 83, 79);
    font-weight: bold;
  }

  .demo-ruleForm {
    margin-top: 20px;
  }

  .required-tag {
    color: #d9534f;
  }

  .submit-btn {
    margin-top: 50px;
  }

  .pagination {
    margin-top: 15px;
  }

  .tableTitle {
    position: relative;
    margin: 30px auto;
    // width: 600px;
    height: 1px;
    background-color: #d4d4d4;
    text-align: center;
    font-size: 16px;
    color: rgba(101, 101, 101, 1);
  }

  .midText {
    position: absolute;
    left: 50%;
    background-color: #ffffff;
    padding: 0 15px;
    transform: translateX(-50%) translateY(-50%);
  }

  .more {
    display: block;
    /* width: 31em; */
    word-break: keep-all;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .el-step__icon {
    width: 24px;
  }

  .applyBilling {
    .demo-ruleForm {
      .el-select {
        width: 100%;
      }
      .el-autocomplete {
        width: 100%;
      }
    }
  }
  .lookeOerderFrom {
    .el-form-item {
      height: 100%;
      padding-left: 10px;
      border: 1px solid #ccc;
      margin-right: -1px;
      margin-bottom: -1px;
      // border-bottom-width: 0;
      .el-form-item__label {
        line-height: 30px;
      }
      .el-form-item__content {
        line-height: 30px;
      }
    }
    .el-row {
      .el-col-12 {
        .el-form-item {
          border-bottom-width: 0;
        }
      }
    }
    .pre-img {
        margin-top: 4px;
      }
  }
  .leaveWord {
    color: rgb(16, 133, 16);
    font-size: 18px;
  }
  .steps {
    .el-step__main {
      // min-width: 110px;
      width: 100%;
      .el-step__title {
        text-align: center;
        font-size: 15px;
        width: 100%;
        line-height: 20px;
      }
    }
    .el-step:nth-child(odd) {
      .el-step__main {
        position: absolute;
        top: -40px;
      }
    }
    .el-step:nth-child(even) {
      .el-step__main {
        margin-top: 15px;
      }
    }
    .el-steps--vertical {
      width: 420px;
      margin: 0 auto;
    }
  }
}
.condition-list {
  width: 150px;
}
.poptip-condition {
  display: block;
  margin: 10px 0;
  .poptip-condition-item {
    line-height: 25px;
    cursor: pointer;
  }
  .poptip-condition-add {
    font-size: 15px;
  }
}
.demo-dynamic {
  padding-left: 10px;
  .el-form-item {
    margin-bottom: 12px;
  }
  .el-input {
    width: 240px;
  }
  .el-date-editor {
    width: 240px;
  }
  .el-button {
    padding: 8px 15px;
    vertical-align: baseline;
  }
  .el-form-item__error {
    padding-top: 0;
  }
}
.el-main .ivu-poptip .ivu-poptip-popper .ivu-poptip-content .ivu-poptip-inner {
  min-width: 420px;
  // height: 300px;
  overflow-y: scroll;
}
.el-main
  .poptip-condition
  .ivu-poptip-popper
  .ivu-poptip-content
  .ivu-poptip-inner {
  min-width: 180px;
}
.ivu-poptip-body {
  padding: 8px 12px;
}
// 操作按钮颜色 disabled
.el-button--danger.is-disabled,
.el-button--danger.is-disabled:active,
.el-button--danger.is-disabled:focus,
.el-button--danger.is-disabled:hover {
  color: #fff;
  background-color: #b0e2ff;
  border-color: #b0e2ff;
}
//  操作按钮颜色
.el-button--danger,
.el-button--danger:active,
.el-button--danger:focus,
.el-button--danger:hover {
  color: #fff;
  background-color: #249dff;
  border-color: #249dff;
}
.tag2 {
  display: block;
  font-size: 15px;
  float: right;
  text-align: center;
  border:1px solid rgba(36,157,255,1);
  border-radius:12px;
  padding: 2px 13px;
}
.down-execel1 {
  display: block;
  font-size: 15px;
  float: right;
  margin-right: 20px;
  border: 1px solid rgba(36, 157, 255, 1);
  border-radius: 12px;
  padding: 2px 13px;
}
.lookup-list {

}
.soft-writing1 {
  display: block;
  font-size: 15px;
  float: right;
  margin-right: 20px;
  text-align: center;
  border:1px solid rgba(36,157,255,1);
  border-radius:12px;
  padding: 2px 13px;
  color: rgba(36,157,255,1);
}
.soft-patent1 {
  display: block;
  font-size: 15px;
  float: right;
  margin-right: 20px;
  text-align: center;
  border:1px solid rgba(36,157,255,1);
  border-radius:12px;
  padding: 2px 13px;
  color: rgba(36,157,255,1);
}
.no-partent1 {
  display: block;
  font-size: 15px;
  float: right;
  margin-right: 20px;
  padding: 2px 13px;
  border: 1px solid rgba(36, 157, 255, 1);
  border-radius: 12px;
  text-align: center;
  background: rgba(36, 157, 255, 1);
  color: #fff;
}
.soft-confirm1 {
  display: block;
  font-size: 15px;
  float: right;
  margin-right: 20px;
  text-align: center;
  border:1px solid rgba(36,157,255,1);
  border-radius:12px;
  padding: 2px 13px;
  color:rgba(36,157,255,1);
}
.click-confirm1 {
  display: block;
  padding: 2px 13px;
  font-size: 15px;
  float: right;
  margin-right: 20px;
  border: 1px solid rgba(36, 157, 255, 1);
  border-radius: 12px;
  text-align: center;
  background: rgba(36, 157, 255, 1);
  color: #fff;
}
.btns {
  margin-top: 10px;
  text-align: right;
  margin-right: 60px;
}
.tableLastCol {
  padding-right: 15px;
}
.fontgreen {
  color: rgb(73, 150, 124);
  font-weight: 700;
}
.lookOrder-title {
  font-size: 18px;
  margin-right: 30px;
  // font-weight: 700;
}

.userPrompt {
  display: inline-block;
  border-radius: 3px;
  cursor: pointer;
  padding: 11px 15px;
  color: #e6a23c;
  background: #fdf6ec;
  border-color: #f5dab1;
}
.file-btns {
  margin: 10px 0;
}
.file-box {
  -webkit-display: flex;
  height: 30px;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: left;
  justify-content: left;

  // height: 30px;
  // display: flex;
  // align-items: center;
  // justify-content: center;
}
.a {
  text-decoration: underline;
}
.preview-img-wrap {
  display: flex;
  align-items: center;
  .el-image {
    width: 20px;
    height: 20px;
    margin-right: 10px;
    image {
      width: 100%;
      height: 100%;
      display: block;
    }
  }
}
.messageList {
  .messagebox {
    width: 100%;
    background: #eef1f3;
  }

  .messageBackground_l {
    background: #fff;
  }
  .messageBackground_r {
    background: #c9e7ff;
  }
  .item {
    width: 100%;
    margin-bottom: 10px;
    .item_user {
      display: inline-block;
      width: 60px;
      font-size: 16px;
      font-weight: bold;
    }
    .item_message {
      max-width: calc(100% - 170px);
      display: inline-block;
      padding: 10px 15px;
      box-sizing: border-box;
      margin-left: 15px;
      border-radius: 5px;
      vertical-align: top;
      // margin-right: 90px;
    }
    .item_time {
      font-size: 12px;
      display: block;
      padding-left: 80px;
      margin-bottom: 5px;
      color: #ccc;
    }
    .deduction_message {
      margin: 20px 0 0 80px;
      max-width: calc(100% - 170px);
      padding: 10px 15px;
      border-radius: 5px;
    }
  }
  .agent_item {
    width: 100%;
    margin-bottom: 10px;
    position: relative;
    box-sizing: border-box;
    padding-top: 20px;
    .item_user {
      display: inline-block;
      width: 60px;
      font-size: 16px;
      font-weight: bold;
    }
    .item_time {
      position: absolute;
      right: 95px;
      top: 0px;
      font-size: 12px;
      display: block;
      // padding-right: 80px;
      margin-bottom: 5px;
      color: #ccc;
    }
    .item_message {
      max-width: calc(100% - 180px);
      display: inline-block;
      padding: 10px 15px;
      box-sizing: border-box;
      margin-right: 30px;
      border-radius: 5px;
      vertical-align: top;
      // margin-left: 80px;
    }
  }
}
// .el-collapse {
// 	.el-collapse-item {
// 		.el-collapse-item__content {
// 			max-height: 1000px;
// 			overflow-y: auto;
// 		}
// 	}
// }
.file_download {
  display:block;
  width: 18px;
  height: 24px;
  background:url('../../../../assets/img/图标.png') no-repeat;
  background-position:-353px -317px;
  margin-right: 10px;
}
.myOrder .lookeOerderFrom .el-form-item {
  margin-right: 0px!important;
}
.time_line{
  float: right;
  font-size: 15px;
}
</style>